package com.atguigu.oss.controller;

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author ct_start
 * @create 2021 -08 -11
 **/
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
@Api(value = "讲师头像上传")
public class OssController {

    @Resource
    private OssService ossService;

    @ApiOperation(value = "头像上传")
    @PostMapping
    public R uploadOssFile(MultipartFile file){
        // 获取文件上传
        // 返回上传的路径
        String url=ossService.uploadFileAvatar(file);
        System.out.println(url);
        return  R.ok().data("url",url);
    }

}
